package com.ttjj.enums;

import com.alibaba.fastjson.annotation.JSONField;
import com.ttjj.entity.player.PlayerStateVo;
import org.testng.collections.Sets;

import java.util.List;
import java.util.Set;

/**
 * 道具类型
 */
public enum EnumPropType {
    Unknown(0),
    /**
     * 靴子
     * 在泥地上的行动速度与平地一致，本场比赛永久有效。
     */
    Shoe(1),
    /**
     * 背包
     */
    Bag(2),
    /**
     * 锄头
     */
    Shovel(3),
    /**
     * 地雷
     */
    Earthquake(4);

    private int value;

    private EnumPropType(int value) {
        this.value = value;
    }

    @JSONField(
            serialize = false
    )
    public int get() {
        return this.value;
    }

    /**
     * 是否只有敌人持有动物
     *
     * @param stateVo
     * @param isEnemyHasAnimal
     * @return
     */
    public Double getWeight(PlayerStateVo stateVo, boolean isEnemyHasAnimal) {
        List<EnumPropType> delivered = stateVo.getHoldingProps();
        Set<EnumPropType> propTypes = Sets.newHashSet(delivered);
        Double weight;
        if (this == EnumPropType.Shoe) {
            if (!propTypes.contains(this)) {
                weight = 1.5d;
            } else {
                weight = 100d;
            }
        } else if (this == EnumPropType.Bag) {
            weight = 1.5d;
        } else if (this == EnumPropType.Shovel) {
//            if (!propTypes.contains(this)) {
//                weight = 1.5d;
//            } else {
                weight = 100d;
//            }
        } else if (this == EnumPropType.Earthquake && isEnemyHasAnimal) {
            weight = 100d;
        } else {
            weight = 0.5d;
        }

        return weight;
    }
}
